# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Sandro Cumerlato <sandro.cumerlato@gmail.com>

_realname=kiss_fft
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_uglyver=1_3_0
pkgver=${_uglyver//_/.}
pkgrel=2
pkgdesc="A Fast Fourier Transform based up on the principle: Keep It Simple, Stupid (mingw-w64)"
url="https://kissfft.sourceforge.io/"
arch=('any')
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("https://sourceforge.net/projects/kissfft/files/kissfft/v${_uglyver}/kiss_fft${_uglyver//_/}.tar.gz")
sha256sums=('cd971c5de6e4712b9ffda5240716fd447480af866ba61446e3a4a15103ba5bf0')

prepare() {
  cd "kiss_fft${_uglyver//_/}"
  make clean
}

build() {
  cd "kiss_fft${_uglyver//_/}"
  gcc -shared ${CFLAGS} -ffast-math -fomit-frame-pointer -dA -fverbose-asm -o kiss_fft.dll -Wl,--out-implib,libkiss_fft.dll.a kiss_fft.c
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/include/${_realname}
  cd "${srcdir}/kiss_fft${_uglyver//_/}"
  install -m644 kiss_fft.dll "${pkgdir}${MINGW_PREFIX}/bin/"
  install -m644 libkiss_fft.dll.a "${pkgdir}${MINGW_PREFIX}/lib/"
  install -m644 kiss_fft.h "${pkgdir}${MINGW_PREFIX}/include/${_realname}"
}
